import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { BaseItem } from "../../common/BaseItem";
import { PetCpnRankRewardItem } from "./PetCpnRankRewardItem";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { PetArenaRewardInfo } from "../../../resource/info/PetArenaRewardInfo";
import { SPetArenaInfo } from "../../../../../Message/Game/SPetArenaInfo";
import { ItemData } from "../../../resource/info/ItemData";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { PetCpnRewardUtil } from "./info/PetCpnRewardUtil";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class PetCpnDrRenderder
    
    export  class PetCpnDrRenderder extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ configUI(): void
        {
            super.configUI();
            this._bg = ObjCreate.createBg(0, 0, 112, 145, this, ImagesConst.RechargeBottom);
            var loc1=new GTextFormat("", 12, 16742658, true, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._nameBg = ObjCreate.createBg(0, 5, 120, 20, this, ImagesConst.FightingStrgBg);
            this._nameTxt = ObjCreate.createTextField("", 0, 5, 120, 20, this, loc1);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._itemBg = ObjCreate.createBg(25, 35, 64, 64, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.move(27, 37);
            this._baseItem.setSize(60, 60);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            this._baseItem.setAmountLabelPos(0, 40);
            addChild(this._baseItem);
            this._rewardItem = new PetCpnRankRewardItem();
            this._rewardItem.x = 5;
            this._rewardItem.y = 105;
            this.addChild(this._rewardItem);
            this._rewardTxt = ObjCreate.createTextField("", 0, 127, 120, 20, this, GlobalStyle.textFormatOrange);
            this._rewardTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            ObjCreate.createBg(0, 148, 112, 35, this, ImagesConst.FightingStrgBg);
            this._serverTxt = ObjCreate.createTextField("", 0, 150, 120, 20, this);
            this._serverTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._playerNameTxt = ObjCreate.createTextField("", 0, 167, 120, 20, this, GlobalStyle.textFormat6);
            this._playerNameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc2=null;
            super.data = arg1;
            this._rewardInfo = arg1["reward"] as PetArenaRewardInfo;
            this._arenaInfo = arg1["arenaInfo"] as SPetArenaInfo;
            var loc1=this._rewardInfo.itemDataArray[0] as ItemData;
            if (this._rewardInfo) 
            {
                this._baseItem.itemData = loc1;
                if (this._rewardInfo.itemDataArray.length > 1) 
                {
                    loc2 = new PetArenaRewardInfo();
                    loc2.itemDataArray = [this._rewardInfo.itemDataArray[1] as ItemData];
                    this._rewardItem.updateReward(loc2, false);
                    this._rewardTxt.y = 125;
                }
                else 
                {
                    this._rewardTxt.y = 115;
                }
                if (this._rewardInfo.itemData) 
                {
                    this._nameTxt.htmlText = ItemsUtil.getItemName(loc1) + "×" + loc1.itemAmount;
                }
                this._rewardTxt.htmlText = "+" + PetCpnRewardUtil.getStrByReward(this._rewardInfo.reward, "", false);
            }
            if (this._arenaInfo) 
            {
                this._serverTxt.text = PlayerUtil.getProxyAndNameByEntityIdAndName(this._arenaInfo.entityId, "");
                this._playerNameTxt.text = this._arenaInfo.playerName;
            }
            return;
        }

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_rewardTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_rewardItem: PetCpnRankRewardItem;

        /* internal */ /* var */_nameBg: ScaleBitmap;

        /* internal */ /* var */_itemBg: ScaleBitmap;

        /* internal */ /* var */_serverTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_playerNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_rewardInfo: PetArenaRewardInfo;

        /* internal */ /* var */_arenaInfo: SPetArenaInfo;
    }
